package cn.edu.sgu.www.mhxysy.controller.qiling;

import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.CustomMessages;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.dto.qiling.QilingTaozhuangEffectDTO;
import cn.edu.sgu.www.mhxysy.entity.qiling.QilingTaozhuangEffect;
import cn.edu.sgu.www.mhxysy.pager.qiling.QilingTaozhuangEffectPager;
import cn.edu.sgu.www.mhxysy.restful.JsonPage;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.qiling.QilingTaozhuangEffectService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "器灵套装效果管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@RestController
@RequestMapping(path = "/qiling_taozhuang_effect", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class QilingTaozhuangEffectController {

    private final QilingTaozhuangEffectService qilingTaozhuangEffectService;

    @Autowired
    public QilingTaozhuangEffectController(QilingTaozhuangEffectService qilingTaozhuangEffectService) {
        this.qilingTaozhuangEffectService = qilingTaozhuangEffectService;
    }

    @ApiOperation("添加器灵套装效果")
    @ApiOperationSupport(ignoreParameters = "id")
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public JsonResult<Void> insert(@Validated QilingTaozhuangEffectDTO qilingTaozhuangEffectDTO) {
        qilingTaozhuangEffectService.insert(qilingTaozhuangEffectDTO);

        return JsonResult.success(CustomMessages.INSERT_SUCCESS);
    }

    @ApiOperation("通过ID修改器灵套装效果")
    @RequestMapping(value = "/updateById", method = RequestMethod.POST)
    public JsonResult<Void> updateById(@Validated QilingTaozhuangEffectDTO qilingTaozhuangEffectDTO) {
        qilingTaozhuangEffectService.updateById(qilingTaozhuangEffectDTO);

        return JsonResult.success(CustomMessages.UPDATE_SUCCESS);
    }

    @ApiOperation("分页查询器灵套装效果列表")
    @RequestMapping(value = "/selectByPage", method = RequestMethod.GET)
    public JsonResult<JsonPage<QilingTaozhuangEffect>> selectByPage(QilingTaozhuangEffectPager pager) {
        Page<QilingTaozhuangEffect> page = qilingTaozhuangEffectService.selectByPage(pager);

        return JsonResult.restPage(page);
    }

}